from sendapi.BaseSend import *
from message.BaseType import *
from programdeal import PGS,ProgramArgs
def friendDealMessage(msg,programDict):
    data=FriendMsg(msg)
    print(str(data.time)+"\n"+str(data.bot)+'-'+str(data.senderId)+'-'+str(data.msgText))
    if data.msgText[:3]=='开启 ':
        status=PGS.Program(data.msgText[2:].strips(),programDict).startProgram()
        if status==0:
            FriendApi(bot=data.bot,qq=data.senderId).sendWord('开启成功')
        elif status==1:
            FriendApi(bot=data.bot,qq=data.senderId).sendWord('功能已存在')
        elif status==-1:
            FriendApi(bot=data.bot,qq=data.senderId).sendWord('没那个项目')
    elif data.msgText[:3]=='关闭 ':
        status=PGS.Program(data.msgText[2:].strips(),programDict).stopProgram()
        if status==0:
            FriendApi(bot=data.bot,qq=data.senderId).sendWord('关闭成功')
        else:
            FriendApi(bot=data.bot,qq=data.senderId).sendWord('没那个项目')
    elif data.msgText[:3]=='卸载 ':
        status=PGS.Program(data.msgText[2:].strips(),programDict).stopProgram()
        if status==0:
            FriendApi(bot=data.bot,qq=data.senderId).sendWord('卸载成功')
        elif status==-1:
            FriendApi(bot=data.bot,qq=data.senderId).sendWord('没那个项目')
        elif status==1:
            FriendApi(bot=data.bot,qq=data.senderId).sendWord('请先关闭后再试')
    elif data.msgText=='程序列表':
        strs=PGS.Program('查看类别',programDict).showProgram()
        FriendApi(bot=data.bot,qq=data.senderId).sendWord(strs)
    elif data.msgText=='帮助':
        strs='表着急，在开发'
        FriendApi(bot=data.bot,qq=data.senderId).sendWord(strs)
    else:
        ProgramArgs.SortMsg(data.msgText,programDict)

def groupDealMessage(msg,programDict):
    data=GroupMsg(msg)

def friendDealEvent(msg,programDict):
        pass

def groupDealEvent(msg,programDict):
        pass
